package com.hsj.goldstore.utils;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/3/21.
 * 活动管理类
 */

public class ActivityCollector {
    public static List<Activity> activities = new ArrayList<>();

    /**
     * @param activity 添加
     */
    public static void addActivity(Activity activity) {

        if (activities.contains(activity)) {
            return;
        }
        activities.add(activity);
    }

    /**
     * @param activity 删除
     */
    public static void removeActiivity(Activity activity) {
        if (activities.contains(activity)) {
            activities.remove(activity);
        }
    }

    /**
     * 清空所有活动
     */
    public static void removeAllActivity() {
        for (Activity activity : activities) {
            if (!activity.isFinishing()) {
                activity.finish();
            }
        }
    }
}
